/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * EditorProfesionalDlg.java
 *
 * Created on 05-ene-2012, 0:57:53
 */
package vista.personas.profesionales;

import com.toedter.calendar.JDateChooser;
import java.util.List;
import java.util.Set;
import javax.swing.DefaultListModel;
import javax.swing.JComboBox;
import javax.swing.JList;
import javax.swing.JTextField;
import util.GestorComponenteVista;
import util.components.IntegerTextField;
import util.validation.annotation.NotEmpty;

/**
 *
 * @author Raul
 */
public class EditorProfesionalDlg extends javax.swing.JDialog {
     
    private GestorVistaProfesionalDlg gestorVista;
    
    /** Creates new form EditorPeofesionalDlg */
    public EditorProfesionalDlg(java.awt.Frame parent, boolean modal) {
        super(parent, modal);
        initComponents();
        setLocationRelativeTo(null);
    }
    
    public EditorProfesionalDlg( GestorVistaProfesionalDlg gestorVista) {
        super();
        this.gestorVista = gestorVista;
        initComponents();
        setLocationRelativeTo(null);
    }
    public GestorVistaProfesionalDlg getGestorVista() {
        return gestorVista;
    }

    public void setGestorVista(GestorVistaProfesionalDlg gestorVista) {
        this.gestorVista = gestorVista;
    }
    
    @NotEmpty
    public JTextField getNombreTxt() {
        return nombreTxt;
    }
    
    @NotEmpty
    public JTextField getApellidoTxt() {
        return apellidoTxt;
    }
    
    @NotEmpty
    public JComboBox getSexoCmb() {
        return sexoCmb;
    }
    
    @NotEmpty
    public JDateChooser getFechaNacimientoDat() {
        return fechaNacimientoDate;
    }
    
    @NotEmpty
    public JTextField getCalleTxt() {
        return calleTxt;
    }
    
    @NotEmpty
    public IntegerTextField getAlturaTxt() {
        return alturaTxt;
    }

    public JTextField getBarrioTxt() {
        return barrioTxt;
    }

    public JTextField getEmailTxt() {
        return emailTxt;
    }

    public IntegerTextField getPisoTxt() {
        return pisoTxt;
    }

    public JTextField getDepartamentoTxt() {
        return departamentoTxt;
    }
    
    @NotEmpty
    public JComboBox getLocalidadCmb() {
        return localidadCmb;
    }

    public JComboBox getProvinciaCmb() {
        return provinciaCmb;
    }

    public IntegerTextField getCodigoPostalTxt() {
        return codigoPostalTxt;
    }

    public JTextField getCodAreaTxt() {
        return codAreaTxt;
    }

    public IntegerTextField getNroTelefonoTxt() {
        return nroTelefonoTxt;
    }
    
    @NotEmpty
    public JComboBox getTipoDniCmb() {
        return documentoPnl.getTipoDniCmb();
    }
    
    @NotEmpty
    public IntegerTextField getNroDniTxt() {
        return documentoPnl.getNumeroDniTxt();
    }
    
    @NotEmpty
    public JTextField getMatriculaTxt() {
        return matriculaTxt;
    }
    
    @NotEmpty(mensaje="Debe especificar alguna especialidad para el profesional")
    public JList getEspecialidadesLst() {
        return especialidadesLst;
    }

    public JList getTelefonosLst() {
        return telefonosLst;
    }

    public void cargarComboProvincia(List provincias) {
        GestorComponenteVista.cargarCombo(provinciaCmb, provincias);
    }

    public void cargarComboLocalidad(List localidades){
        GestorComponenteVista.cargarCombo(localidadCmb, localidades);
    }
    
    public void cargarComboEspecialidad(List especialidades){
        GestorComponenteVista.cargarCombo(especialidadCmb, especialidades);
    }
    
    public void cargarListaEspecialidades(Set especialidades){
        GestorComponenteVista.cargarLista(especialidadesLst, especialidades);
        GestorComponenteVista.quitarDatosCombo(especialidadCmb, especialidades);
    }
    
    public void cargarListaTelefonos(Set telefonos){
        GestorComponenteVista.cargarLista(telefonosLst, telefonos);
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        gradientPanel1 = new util.components.GradientPanel();
        matriculaTxt = new javax.swing.JTextField();
        jLabel9 = new javax.swing.JLabel();
        datosPersonalesPnl = new javax.swing.JPanel();
        jLabel1 = new javax.swing.JLabel();
        nombreTxt = new util.components.CamelCaseTextField();
        jLabel2 = new javax.swing.JLabel();
        apellidoTxt = new util.components.CamelCaseTextField();
        jLabel3 = new javax.swing.JLabel();
        sexoCmb = new javax.swing.JComboBox();
        jLabel4 = new javax.swing.JLabel();
        fechaNacimientoDate = new com.toedter.calendar.JDateChooser();
        jLabel14 = new javax.swing.JLabel();
        emailTxt = new javax.swing.JTextField();
        documentoPnl = new util.components.DocumentoPnl();
        especialidadesPnl = new javax.swing.JPanel();
        jScrollPane2 = new javax.swing.JScrollPane();
        especialidadesLst = new javax.swing.JList();
        especialidadCmb = new javax.swing.JComboBox();
        quitarEspecialidadBtn = new javax.swing.JButton();
        addEspecialidadBtn = new javax.swing.JButton();
        telefonosPnl = new javax.swing.JPanel();
        jScrollPane1 = new javax.swing.JScrollPane();
        telefonosLst = new javax.swing.JList();
        addTelefonoBtn = new javax.swing.JButton();
        quitarTelefonoBtn = new javax.swing.JButton();
        nroTelefonoTxt = new util.components.IntegerTextField();
        codAreaTxt = new javax.swing.JFormattedTextField();
        jPanel1 = new javax.swing.JPanel();
        calleTxt = new util.components.CamelCaseTextField();
        jLabel5 = new javax.swing.JLabel();
        jLabel10 = new javax.swing.JLabel();
        alturaTxt = new util.components.IntegerTextField();
        jLabel11 = new javax.swing.JLabel();
        pisoTxt = new util.components.IntegerTextField();
        jLabel12 = new javax.swing.JLabel();
        departamentoTxt = new javax.swing.JTextField();
        barrioTxt = new javax.swing.JTextField();
        jLabel13 = new javax.swing.JLabel();
        jLabel7 = new javax.swing.JLabel();
        codigoPostalTxt = new util.components.IntegerTextField();
        buscarLocalidadBtn = new javax.swing.JButton();
        jLabel8 = new javax.swing.JLabel();
        provinciaCmb = new javax.swing.JComboBox();
        jLabel6 = new javax.swing.JLabel();
        localidadCmb = new javax.swing.JComboBox();
        addLocalidadBtn = new javax.swing.JButton();
        cancelarBtn = new javax.swing.JButton();
        guardarBtn = new javax.swing.JButton();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
        setTitle("Editar Profesional");
        setBounds(new java.awt.Rectangle(0, 0, 0, 0));
        setModal(true);
        setResizable(false);

        gradientPanel1.setBorder(javax.swing.BorderFactory.createLineBorder(java.awt.Color.lightGray));
        gradientPanel1.setGradientColor1(java.awt.Color.white);
        gradientPanel1.setGradientColor2(javax.swing.UIManager.getDefaults().getColor("Panel.background"));

        jLabel9.setText("Matrícula");

        datosPersonalesPnl.setBorder(javax.swing.BorderFactory.createTitledBorder("Datos Personales"));
        datosPersonalesPnl.setOpaque(false);

        jLabel1.setText("Nombre");

        jLabel2.setText("Apellido");

        jLabel3.setText("Sexo");

        sexoCmb.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "", "Hombre", "Mujer" }));

        jLabel4.setText("Fecha de Nacimiento");

        fechaNacimientoDate.setMaxSelectableDate(new java.util.Date());

        jLabel14.setText("Email");

        documentoPnl.setBorder(javax.swing.BorderFactory.createEmptyBorder(1, 1, 1, 1));
        documentoPnl.setOpaque(false);

        javax.swing.GroupLayout datosPersonalesPnlLayout = new javax.swing.GroupLayout(datosPersonalesPnl);
        datosPersonalesPnl.setLayout(datosPersonalesPnlLayout);
        datosPersonalesPnlLayout.setHorizontalGroup(
            datosPersonalesPnlLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(datosPersonalesPnlLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(datosPersonalesPnlLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel3)
                    .addComponent(jLabel1)
                    .addComponent(jLabel14))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 18, Short.MAX_VALUE)
                .addGroup(datosPersonalesPnlLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addGroup(datosPersonalesPnlLayout.createSequentialGroup()
                        .addGroup(datosPersonalesPnlLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(datosPersonalesPnlLayout.createSequentialGroup()
                                .addComponent(nombreTxt, javax.swing.GroupLayout.PREFERRED_SIZE, 186, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                .addComponent(jLabel2))
                            .addGroup(datosPersonalesPnlLayout.createSequentialGroup()
                                .addComponent(sexoCmb, javax.swing.GroupLayout.PREFERRED_SIZE, 111, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(jLabel4)))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addGroup(datosPersonalesPnlLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                            .addComponent(fechaNacimientoDate, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, 142, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(apellidoTxt, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, 142, javax.swing.GroupLayout.PREFERRED_SIZE)))
                    .addComponent(emailTxt))
                .addContainerGap())
            .addComponent(documentoPnl, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, 0, Short.MAX_VALUE)
        );
        datosPersonalesPnlLayout.setVerticalGroup(
            datosPersonalesPnlLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(datosPersonalesPnlLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(datosPersonalesPnlLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(nombreTxt, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(apellidoTxt, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel2)
                    .addComponent(jLabel1))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(datosPersonalesPnlLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(datosPersonalesPnlLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(sexoCmb, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addComponent(jLabel4)
                        .addComponent(jLabel3))
                    .addComponent(fechaNacimientoDate, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(documentoPnl, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(datosPersonalesPnlLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.CENTER)
                    .addComponent(jLabel14)
                    .addComponent(emailTxt, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        especialidadesPnl.setBorder(javax.swing.BorderFactory.createTitledBorder("Especilidades"));
        especialidadesPnl.setOpaque(false);

        especialidadesLst.setModel(new DefaultListModel()
        );
        especialidadesLst.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION);
        jScrollPane2.setViewportView(especialidadesLst);

        especialidadCmb.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" }));

        quitarEspecialidadBtn.setIcon(new javax.swing.ImageIcon(getClass().getResource("/resources/ArrowUp_24.png"))); // NOI18N
        quitarEspecialidadBtn.setBorderPainted(false);
        quitarEspecialidadBtn.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                quitarEspecialidadBtnActionPerformed(evt);
            }
        });

        addEspecialidadBtn.setIcon(new javax.swing.ImageIcon(getClass().getResource("/resources/ArrowDown_24.png"))); // NOI18N
        addEspecialidadBtn.setBorderPainted(false);
        addEspecialidadBtn.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                addEspecialidadBtnActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout especialidadesPnlLayout = new javax.swing.GroupLayout(especialidadesPnl);
        especialidadesPnl.setLayout(especialidadesPnlLayout);
        especialidadesPnlLayout.setHorizontalGroup(
            especialidadesPnlLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(especialidadesPnlLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(especialidadesPnlLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(especialidadesPnlLayout.createSequentialGroup()
                        .addComponent(especialidadCmb, javax.swing.GroupLayout.PREFERRED_SIZE, 378, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(addEspecialidadBtn, javax.swing.GroupLayout.PREFERRED_SIZE, 24, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addComponent(quitarEspecialidadBtn, javax.swing.GroupLayout.PREFERRED_SIZE, 25, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(especialidadesPnlLayout.createSequentialGroup()
                        .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 450, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(0, 4, Short.MAX_VALUE)))
                .addContainerGap(17, Short.MAX_VALUE))
        );
        especialidadesPnlLayout.setVerticalGroup(
            especialidadesPnlLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(especialidadesPnlLayout.createSequentialGroup()
                .addGap(6, 6, 6)
                .addGroup(especialidadesPnlLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.CENTER)
                    .addComponent(quitarEspecialidadBtn, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(addEspecialidadBtn, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(especialidadCmb, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 80, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap())
        );

        telefonosPnl.setBorder(javax.swing.BorderFactory.createTitledBorder("Teléfonos"));
        telefonosPnl.setOpaque(false);

        telefonosLst.setModel(new DefaultListModel());
        telefonosLst.setLayoutOrientation(javax.swing.JList.VERTICAL_WRAP);
        telefonosLst.setMinimumSize(new java.awt.Dimension(250, 0));
        telefonosLst.setVisibleRowCount(2);
        jScrollPane1.setViewportView(telefonosLst);

        addTelefonoBtn.setIcon(new javax.swing.ImageIcon(getClass().getResource("/resources/phone_add.png"))); // NOI18N
        addTelefonoBtn.setToolTipText("Agregar un teléfono");
        addTelefonoBtn.setBorderPainted(false);
        addTelefonoBtn.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                addTelefonoBtnActionPerformed(evt);
            }
        });

        quitarTelefonoBtn.setIcon(new javax.swing.ImageIcon(getClass().getResource("/resources/phone_delete.png"))); // NOI18N
        quitarTelefonoBtn.setToolTipText("Quitar el telefono seleccionado de la lista");
        quitarTelefonoBtn.setBorderPainted(false);
        quitarTelefonoBtn.setHorizontalAlignment(javax.swing.SwingConstants.LEFT);
        quitarTelefonoBtn.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                quitarTelefonoBtnActionPerformed(evt);
            }
        });

        nroTelefonoTxt.setAgruparMiles(false);

        try {
            codAreaTxt.setFormatterFactory(new javax.swing.text.DefaultFormatterFactory(new javax.swing.text.MaskFormatter("######")));
        } catch (java.text.ParseException ex) {
            ex.printStackTrace();
        }
        codAreaTxt.setFocusLostBehavior(javax.swing.JFormattedTextField.PERSIST);

        javax.swing.GroupLayout telefonosPnlLayout = new javax.swing.GroupLayout(telefonosPnl);
        telefonosPnl.setLayout(telefonosPnlLayout);
        telefonosPnlLayout.setHorizontalGroup(
            telefonosPnlLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(telefonosPnlLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(telefonosPnlLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 459, Short.MAX_VALUE)
                    .addGroup(telefonosPnlLayout.createSequentialGroup()
                        .addComponent(codAreaTxt, javax.swing.GroupLayout.PREFERRED_SIZE, 123, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(nroTelefonoTxt, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(addTelefonoBtn)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(quitarTelefonoBtn)))
                .addContainerGap())
        );
        telefonosPnlLayout.setVerticalGroup(
            telefonosPnlLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(telefonosPnlLayout.createSequentialGroup()
                .addGroup(telefonosPnlLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.CENTER)
                    .addComponent(quitarTelefonoBtn)
                    .addComponent(addTelefonoBtn)
                    .addComponent(nroTelefonoTxt, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(codAreaTxt, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 54, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder("Domicilio"));
        jPanel1.setOpaque(false);

        jLabel5.setText("Calle");

        jLabel10.setText("Altura");

        jLabel11.setText("Barrio");

        jLabel12.setText("Departamento");

        jLabel13.setText("Piso");

        jLabel7.setText("C.P.");

        codigoPostalTxt.setAgruparMiles(false);
        codigoPostalTxt.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                buscarLocalidadBtnActionPerformed(evt);
            }
        });
        codigoPostalTxt.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyTyped(java.awt.event.KeyEvent evt) {
                codigoPostalTxtKeyTyped(evt);
            }
        });

        buscarLocalidadBtn.setIcon(new javax.swing.ImageIcon(getClass().getResource("/resources/zoom.png"))); // NOI18N
        buscarLocalidadBtn.setToolTipText("Buscar localidad");
        buscarLocalidadBtn.setBorderPainted(false);
        buscarLocalidadBtn.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                buscarLocalidadBtnActionPerformed(evt);
            }
        });

        jLabel8.setText("Provincia");

        provinciaCmb.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                provinciaCmbActionPerformed(evt);
            }
        });

        jLabel6.setText("Localidad");

        addLocalidadBtn.setIcon(new javax.swing.ImageIcon(getClass().getResource("/resources/add_24.png"))); // NOI18N
        addLocalidadBtn.setToolTipText("Agregar una localidad");
        addLocalidadBtn.setBorderPainted(false);
        addLocalidadBtn.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                addLocalidadBtnActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabel5)
                            .addComponent(jLabel11))
                        .addGap(21, 30, 30)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
                                .addComponent(calleTxt)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(jLabel10)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(alturaTxt, javax.swing.GroupLayout.PREFERRED_SIZE, 84, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
                                .addGap(0, 1, Short.MAX_VALUE)
                                .addComponent(barrioTxt, javax.swing.GroupLayout.PREFERRED_SIZE, 157, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(jLabel13)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(pisoTxt, javax.swing.GroupLayout.PREFERRED_SIZE, 51, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(jLabel12)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(departamentoTxt, javax.swing.GroupLayout.PREFERRED_SIZE, 33, javax.swing.GroupLayout.PREFERRED_SIZE))))
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addComponent(jLabel7)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addComponent(provinciaCmb, javax.swing.GroupLayout.PREFERRED_SIZE, 214, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
                        .addComponent(jLabel6)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(jPanel1Layout.createSequentialGroup()
                                .addComponent(localidadCmb, javax.swing.GroupLayout.PREFERRED_SIZE, 360, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(addLocalidadBtn, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addGroup(jPanel1Layout.createSequentialGroup()
                                .addComponent(codigoPostalTxt, javax.swing.GroupLayout.PREFERRED_SIZE, 70, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(buscarLocalidadBtn)
                                .addGap(18, 18, 18)
                                .addComponent(jLabel8)))))
                .addContainerGap())
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(calleTxt, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel5)
                    .addComponent(jLabel10)
                    .addComponent(alturaTxt, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel11)
                    .addComponent(pisoTxt, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel12)
                    .addComponent(departamentoTxt, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(barrioTxt, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel13))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.CENTER)
                    .addComponent(jLabel7)
                    .addComponent(codigoPostalTxt, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(buscarLocalidadBtn)
                    .addComponent(jLabel8)
                    .addComponent(provinciaCmb, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(localidadCmb, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addComponent(jLabel6))
                    .addComponent(addLocalidadBtn, javax.swing.GroupLayout.PREFERRED_SIZE, 0, Short.MAX_VALUE))
                .addContainerGap())
        );

        javax.swing.GroupLayout gradientPanel1Layout = new javax.swing.GroupLayout(gradientPanel1);
        gradientPanel1.setLayout(gradientPanel1Layout);
        gradientPanel1Layout.setHorizontalGroup(
            gradientPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(gradientPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(gradientPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(datosPersonalesPnl, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addGroup(gradientPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(gradientPanel1Layout.createSequentialGroup()
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(gradientPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(telefonosPnl, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(especialidadesPnl, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
                    .addGroup(gradientPanel1Layout.createSequentialGroup()
                        .addGap(16, 16, 16)
                        .addComponent(jLabel9)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(matriculaTxt, javax.swing.GroupLayout.PREFERRED_SIZE, 125, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(0, 0, Short.MAX_VALUE)))
                .addContainerGap())
        );
        gradientPanel1Layout.setVerticalGroup(
            gradientPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(gradientPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(gradientPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(gradientPanel1Layout.createSequentialGroup()
                        .addComponent(telefonosPnl, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(18, 18, 18)
                        .addGroup(gradientPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel9)
                            .addComponent(matriculaTxt, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                    .addComponent(datosPersonalesPnl, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 3, Short.MAX_VALUE)
                .addGroup(gradientPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jPanel1, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(especialidadesPnl, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(15, Short.MAX_VALUE))
        );

        cancelarBtn.setIcon(new javax.swing.ImageIcon(getClass().getResource("/resources/cancel.png"))); // NOI18N
        cancelarBtn.setText("Cancelar");
        cancelarBtn.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                cancelarBtnActionPerformed(evt);
            }
        });

        guardarBtn.setIcon(new javax.swing.ImageIcon(getClass().getResource("/resources/disk.png"))); // NOI18N
        guardarBtn.setText("Guardar");
        guardarBtn.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                guardarBtnActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addComponent(guardarBtn)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(cancelarBtn)
                .addContainerGap())
            .addComponent(gradientPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addComponent(gradientPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(guardarBtn)
                    .addComponent(cancelarBtn))
                .addContainerGap())
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void addTelefonoBtnActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_addTelefonoBtnActionPerformed
        if (!nroTelefonoTxt.getText().equals("")) {
            GestorComponenteVista.agregarDatoLista(telefonosLst,
                    getGestorVista().nuevoTelefono(codAreaTxt.getText().trim(),
                        nroTelefonoTxt.getValue()));
        }
	}//GEN-LAST:event_addTelefonoBtnActionPerformed

    private void quitarTelefonoBtnActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_quitarTelefonoBtnActionPerformed
        if(!telefonosLst.isSelectionEmpty())
            GestorComponenteVista.quitarDatoLista(telefonosLst, telefonosLst.getSelectedIndex());
	}//GEN-LAST:event_quitarTelefonoBtnActionPerformed

    private void cancelarBtnActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cancelarBtnActionPerformed
        dispose();
    }//GEN-LAST:event_cancelarBtnActionPerformed

    private void guardarBtnActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_guardarBtnActionPerformed
        gestorVista.guardar();
    }//GEN-LAST:event_guardarBtnActionPerformed

    private void quitarEspecialidadBtnActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_quitarEspecialidadBtnActionPerformed
        if(!especialidadesLst.isSelectionEmpty()){
            especialidadCmb.addItem(especialidadesLst.getSelectedValue());
            GestorComponenteVista.quitarDatoLista(especialidadesLst, especialidadesLst.getSelectedIndex());
        }
    }//GEN-LAST:event_quitarEspecialidadBtnActionPerformed

    private void addEspecialidadBtnActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_addEspecialidadBtnActionPerformed
        if (especialidadCmb.getSelectedIndex() != -1) {
            GestorComponenteVista.agregarDatoLista(especialidadesLst, especialidadCmb.getSelectedItem());
            especialidadCmb.removeItem(especialidadCmb.getSelectedItem());
            especialidadCmb.setSelectedIndex(0);
        }
    }//GEN-LAST:event_addEspecialidadBtnActionPerformed

    private void addLocalidadBtnActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_addLocalidadBtnActionPerformed
        getGestorVista().crearLocalidad();
    }//GEN-LAST:event_addLocalidadBtnActionPerformed

    private void provinciaCmbActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_provinciaCmbActionPerformed
        if (provinciaCmb.getSelectedItem()!=null) {
            getGestorVista().cargarLocalidades(provinciaCmb.getSelectedItem());
        }
    }//GEN-LAST:event_provinciaCmbActionPerformed

    private void codigoPostalTxtKeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_codigoPostalTxtKeyTyped
        if (codigoPostalTxt.getText().length() == 5) evt.consume();
    }//GEN-LAST:event_codigoPostalTxtKeyTyped

    private void buscarLocalidadBtnActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buscarLocalidadBtnActionPerformed
        if (codigoPostalTxt.getValue() != null) {
            gestorVista.buscarLocalidad(codigoPostalTxt.getValue());
        }
    }//GEN-LAST:event_buscarLocalidadBtnActionPerformed

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        /* Set the Nimbus look and feel */
        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
        /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
         * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html 
         */
        try {
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                if ("Nimbus".equals(info.getName())) {
                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
                    break;
                }
            }
        } catch (ClassNotFoundException ex) {
            java.util.logging.Logger.getLogger(EditorProfesionalDlg.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(EditorProfesionalDlg.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(EditorProfesionalDlg.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(EditorProfesionalDlg.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }
        //</editor-fold>

        /* Create and display the dialog */
        java.awt.EventQueue.invokeLater(new Runnable() {

            public void run() {
                EditorProfesionalDlg dialog = new EditorProfesionalDlg(new javax.swing.JFrame(), true);
                dialog.addWindowListener(new java.awt.event.WindowAdapter() {

                    @Override
                    public void windowClosing(java.awt.event.WindowEvent e) {
                        System.exit(0);
                    }
                });
                dialog.setVisible(true);
            }
        });
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton addEspecialidadBtn;
    private javax.swing.JButton addLocalidadBtn;
    private javax.swing.JButton addTelefonoBtn;
    private util.components.IntegerTextField alturaTxt;
    private javax.swing.JTextField apellidoTxt;
    private javax.swing.JTextField barrioTxt;
    private javax.swing.JButton buscarLocalidadBtn;
    private javax.swing.JTextField calleTxt;
    private javax.swing.JButton cancelarBtn;
    private javax.swing.JFormattedTextField codAreaTxt;
    private util.components.IntegerTextField codigoPostalTxt;
    private javax.swing.JPanel datosPersonalesPnl;
    private javax.swing.JTextField departamentoTxt;
    private util.components.DocumentoPnl documentoPnl;
    private javax.swing.JTextField emailTxt;
    private javax.swing.JComboBox especialidadCmb;
    private javax.swing.JList especialidadesLst;
    private javax.swing.JPanel especialidadesPnl;
    private com.toedter.calendar.JDateChooser fechaNacimientoDate;
    private util.components.GradientPanel gradientPanel1;
    private javax.swing.JButton guardarBtn;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel10;
    private javax.swing.JLabel jLabel11;
    private javax.swing.JLabel jLabel12;
    private javax.swing.JLabel jLabel13;
    private javax.swing.JLabel jLabel14;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JLabel jLabel9;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JScrollPane jScrollPane2;
    private javax.swing.JComboBox localidadCmb;
    private javax.swing.JTextField matriculaTxt;
    private javax.swing.JTextField nombreTxt;
    private util.components.IntegerTextField nroTelefonoTxt;
    private util.components.IntegerTextField pisoTxt;
    private javax.swing.JComboBox provinciaCmb;
    private javax.swing.JButton quitarEspecialidadBtn;
    private javax.swing.JButton quitarTelefonoBtn;
    private javax.swing.JComboBox sexoCmb;
    private javax.swing.JList telefonosLst;
    private javax.swing.JPanel telefonosPnl;
    // End of variables declaration//GEN-END:variables
    
}
